﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Entities
{
    public class ConnectionString
    {
        public static String password = "139784265";
        public static String username = "sa";
        public static String databaseName = "QuanLyGach";
        public static String ipServer = "192.168.1.35";

        //public static String connectionString = "data source=" + ipServer + "; initial catalog=" + databaseName + ";user id=" + username + ";password=" + password + ";";
        //public static String connectionString = "Data Source=192.168.1.36;Initial Catalog=QuanLyGach;Integrated Security=SSPI;User ID=sa;Password=139784265;";

        //public static String connectionString = "Server=" + ipServer + ";Database=" + databaseName + ";User Id=" +username + ";Password=" + password + ";";
        //public static String connectionString = "Server=192.168.1.35 ; Database= QuanLyGach ;User Id= sa ;Password=123456;";

        public static String getConnectionString()
        {
            String connectionString = "";
            try
            {
                if (File.Exists(Constant.CONST_FILE_NAME_SERVER_CONFIG))
                {
                    ServerConfig sc =  ServerConfigManager.deserializeServerConfig(Constant.CONST_FILE_NAME_SERVER_CONFIG);

                    connectionString = "Server=" + sc.ipServer + ";Database=" + sc.dbName + ";User Id=" + sc.user + ";Password=" + sc.pwd + ";";
                }
                else
                {

                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return connectionString;
        }
    }
}
